package com.jd.jr.insights.dm.dim.service.impl;

import com.alibaba.fastjson.JSON;
import com.jd.jr.insights.dm.dim.dao.DimTransformDao;
import com.jd.jr.insights.dm.dim.dao.impl.DimTransformDaoImpl;
import com.jd.jr.insights.dm.dim.domain.DimTransform;
import com.jd.jr.insights.dm.dim.service.DimTransformService;
import com.jd.jr.insights.dm.dim.util.fastjson.tree.Result;
import com.jd.jr.insights.dm.dim.util.fastjson.tree.ResultCode;

/**
 * Created by Administrator on 2017/7/29.
 */
public class DimTransformServiceImpl implements DimTransformService {
    DimTransformDao dimTransformDao=new DimTransformDaoImpl();

    public String getDimTransformListJson() {
        return JSON.toJSONString(this.dimTransformDao.getList());
    }

    public String getDimTransformListJsonNm() {
        return null;
    }

    public String getDimTransformListInPage(int pageNum) {
        return JSON.toJSONString(this.dimTransformDao.getListInPage(pageNum));
    }

    public String getDimTransformListInPage(int pageNum, DimTransform dimTransform) {
        return JSON.toJSONString(this.dimTransformDao.getListInPage(pageNum,dimTransform));
    }

    public String deleteById(DimTransform dimTransform) {
        if(dimTransformDao.deleteById(dimTransform)==true){
            return JSON.toJSONString(new Result(ResultCode.OK));
        }
        return JSON.toJSONString(new Result(ResultCode.ERROT));
    }

    public String deleteByIds(Integer[] ids) {
        if(ids.length>0) {
            if (dimTransformDao.deleteByIds(ids) == true) {
                return JSON.toJSONString(new Result(ResultCode.OK));
            }
        }
        return JSON.toJSONString(new Result(ResultCode.ERROT));
    }

    public String save(DimTransform dimTransform) {
        if(dimTransformDao.save(dimTransform)==true){
            return JSON.toJSONString(new Result(ResultCode.OK));
        }
        return JSON.toJSONString(new Result(ResultCode.ERROT));
    }

    public String update(DimTransform dimTransform) {
        if(dimTransformDao.update(dimTransform)==true){
            return JSON.toJSONString(new Result(ResultCode.OK));
        }
        return JSON.toJSONString(new Result(ResultCode.ERROT));
    }

    public String getOldTableNameList() {
        return JSON.toJSONString(this.dimTransformDao.getOldTableNameList());
    }

    public String getNewTableNameList() {
        return JSON.toJSONString(this.dimTransformDao.getNewTableNameList());
    }

    public String getNewColumnNameList() {
        return JSON.toJSONString(this.dimTransformDao.getNewColumnNameList());
    }

    public String getOldKeyIdList() {
        return JSON.toJSONString(this.dimTransformDao.getOldKeyIdList());
    }

    public String getOldKeyNameList() {
        return JSON.toJSONString(this.dimTransformDao.getOldKeyNameList());
    }

    public String getBizList() {
        return JSON.toJSONString(this.dimTransformDao.getBizList());
    }
}
